#ifndef DW_GRAPHICS_FRUSTUM_H
#	define DW_GRAPHICS_FRUSTUM_H

#include "boundingvolume.h" 

namespace dw {
	namespace graphics {

using maths::Vector3f;
using maths::Matrix4f;
using maths::Point3f;
using maths::Plane;

struct IntersectionInfo
{
	enum Type
	{
		INTERSECT,
		INSIDE,
		OUTSIDE
	};

	Type type;

};

class Frustum : public IBoundingVolume
{

	enum PlaneType
	{
		PLANE_NEAR = 0,
		PLANE_FAR,
		PLANE_LEFT,
		PLANE_RIGHT,
		PLANE_TOP,
		PLANE_BOTTOM
	};

public:

																	Frustum(const float& fov = 90, const float& aspectRatio = 4 / 3, const float& nearClipDist = 1, const float& farClipDist = 1000);

																	Frustum(const Matrix4f& m);

public:

	const Plane& getPlane(const unsigned i) const ;

	void getVertices(std::vector< Point3f >& vertices) const ;


	/// Test for intersection with a point
	virtual bool intersects(const Point3f& point) const ;
	/// Test for intersection with a bounding sphere
	virtual bool intersects(const BSphere& bsphere) const ;
	/// Test for intersection with an axis aligned bounding box
	virtual bool intersects(const AABBox& aabb) const ;
	/// Test for intersection with an axis aligned bounding box
	virtual bool intersects(const AABBox& aabb, IntersectionInfo& intersectInfo) const ;
	/// Transform this frustum with the given matrix
	virtual void transform(const Matrix4f& m);



	void draw();



	/// Create a Frustum from a projection matrix
	static Frustum fromMatrix(const Matrix4f& m);

private:

	Plane _planes[6];

};

	} // namespace graphics
} // namespace dw

#endif // !DW_GRAPHICS_FRUSTUM_H
